﻿/*
 * KLF Headless Browser
 * Written by Kris Oye <kristianoye@gmail.com>
 * Copyright (C) 2011-2012.  All rights reserved.
 */
namespace KLF.Lib.Browser.DOM
{
    #region Using Statements

    using System.Collections.Generic;

    #endregion

    /// <summary>
    /// The DOMImplementationList interface provides the abstraction of an
    /// ordered collection of DOM implementations, without defining or 
    /// constraining how this collection is implemented. The items in the 
    /// DOMImplementationList are accessible via an integral index, 
    /// starting from 0.
    /// </summary>
    public class DOMImplementationList
    {
        #region Properties

        internal List<DOMImplementation> List { get; set; }

        #endregion

        #region Constructors

        public DOMImplementationList()
        {
            List = new List<DOMImplementation>();
        }

        internal DOMImplementationList(List<DOMImplementation> _listIn)
        {
            List = _listIn;
        }

        #endregion

        #region DOM Level 3 Compliance

        /// <summary>
        /// Returns the indexth item in the collection. If index is greater 
        /// than or equal to the number of DOMImplementations in the list, 
        /// this returns null. 
        /// </summary>
        /// <param name="index">Index into the collection.</param>
        /// <returns></returns>
        public DOMImplementation item(int index)
        {
            if (index > -1 && index < List.Count)
            {
                return List[index];
            }
            return null;
        }

        /// <summary>
        /// Returns the number of DOMIMplementations in the list.
        /// </summary>
        public int length { get { return List.Count; } }

        #endregion
    }
}
